package org.xhy.security.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

@RestController
@RequestMapping("/sms")
@Slf4j
public class SmsCodeController {

    @RequestMapping("/send/{phone}")
    public String Sms(@PathVariable("phone") String phone, HttpServletRequest request){
        //创建验证码
        String code = UUID.randomUUID().toString().substring(0, 6);
        log.info("验证码：{}",code);

        Map<String, String> map = new HashMap<>();
        map.put("code",code);
        map.put("phone",phone);

        request.getSession().setAttribute("sessonCode",map);

        return  "success";
    }
}
